package com.YHVision.qiuzhike.config;

import com.jd.platform.hotkey.client.ClientStarter;
import com.qcloud.cos.ClientConfig;
import lombok.Data;
import org.elasticsearch.http.HttpStats;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * hotkey配置
 *
 * @author <a href="">YHVision-小y</a>
 * @from <a href="todo">爱编程学习圈</a>
 */
@Configuration
@ConfigurationProperties(prefix = "hotkey")
@Data
public class HotkeyConfig  {

    /**
     * etcd服务器地址
     */
    private String etcdServer = "http://127.0.0.1:2379";

    /**
     * 应用名称
     */
    private String appName = "qiuzhike";

    /**
     * 本地缓存大小
     */
    private int caffeineSize = 1000;

    /**
     * 批量推送key周期
     */
    private long pushPeriod = 1000L;

    /**
     * 初始化hotkey
     * @return
     */
    @Bean
    public void initHotkey(){
        ClientStarter.Builder builder = new ClientStarter.Builder();
        ClientStarter starter = builder.setAppName(appName)
                .setCaffeineSize(caffeineSize)
                .setEtcdServer(etcdServer)
                .setPushPeriod(pushPeriod)
                .build();
        starter.startPipeline();
    }

}







